package com.zhongkun.datahome.web.app;

import com.zhongkun.datahome.common.annotation.Log;
import com.zhongkun.datahome.common.core.domain.R;
import com.zhongkun.datahome.common.enums.BusinessType;
import com.zhongkun.datahome.core.service.ISysConfigService;
import com.zhongkun.datahome.service.req.cmd.customer.AppletsPhoneNumberCmd;
import com.zhongkun.datahome.service.service.ICustomerBaseService;
import com.zhongkun.datahome.service.service.IWeixinService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @Author: lifengsheng
 * @Date: 2025/4/18 09:35
 * @Desc
 */
@Api("小程序接口")
@RestController
@RequestMapping("/app")
@Slf4j
public class AppController {

    @Resource
    private ICustomerBaseService customerBaseService;

    @Resource
    private ISysConfigService sysConfigService;

    @ApiOperation("授权登录")
    @PostMapping("/login")
    @Log(title = "登录", businessType = BusinessType.GRANT)
    public R<String> login(@RequestBody AppletsPhoneNumberCmd cmd) {
        return R.ok(customerBaseService.login(cmd));
    }

    @ApiOperation("授权登录")
    @PostMapping("/testLogin")
    @Log(title = "登录", businessType = BusinessType.GRANT)
    public R<String> login(@RequestBody String mobile) {
        return R.ok(customerBaseService.loginByMobile(mobile));
    }

    @ApiOperation("获取是否需要密码登录,1打开，0关闭")
    @GetMapping("/passwordSwitch")
    public R<String> passwordSwitch() {
        return R.ok(sysConfigService.selectConfigByKey("mini.program.password.switch"));
    }
}
